from django.utils import timezone

from django.db import models

from apps.user.models import User


class Case(models.Model):
    """自定义新闻模型类"""
    title = models.CharField(verbose_name='标题', max_length=100)
    case_url = models.CharField(max_length=255,

                                verbose_name="案例url")
    case = models.CharField(max_length=255,
                            default="http://q2fyx80nw.bkt.clouddn.com/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg",
                            verbose_name="案例图片")
    content = models.TextField(verbose_name='正文', default='')
    create_time = models.DateTimeField(verbose_name='创建时间', default=timezone.now)

    click_nums = models.IntegerField(verbose_name='点赞量', default=0)

    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='cases', verbose_name='用户')

    class Meta:
        db_table = 'tb_case'
        verbose_name = '论坛'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.title
